var num = sessionStorage.getItem('num');
console.log(num);
var img_url="http://47.92.37.168/supermarket/img/";
var classify = null;
var start = 0;
var flag_update = true;
map(Number(num));

function map(num) {
    switch (num) {
        case 0:
            classify = 'muying';
            break;
        case 1:
            classify = 'lingshi';
            break;
        case 2:
            classify = 'jiushui';
            break;
        case 3:
            classify = 'liangyou';
            break;
        case 4:
            classify = 'meirong';
            break;
        case 5:
            classify = 'jingxuan';
            break;
        case 6:
            classify = 'jiaqing';
            break;
        case 7:
            classify = 'jiayong';
            break;
        case 8:
            classify = 'shengxian';
            break;
        case 9:
            classify = 'jiayong';
            break;
    }
}

function getData(start, classify) {
//        alert(start)
//        alert(classify)

    $.ajax({
        type: "post"
        , url: "http://47.92.37.168/supermarket/data/get_commodity.php"
        , async: true
        , data: {
            'start': start,
            'classify': classify
        }
        // ,dataType:"jsonp"
        // ,jsonp:"callback"
        , success: function (data) {
            console.log(data);
            if (data) {
                for (var i = 0; i < data.length; i++) {
                    $('.zq').eq(aa).append
                    ("<li id=" + data[i].id + ">" +
                        "<a href='#'>" +
                        "<img src=" + img_url + data[i].img + " class='list_img' />" +
                        "<div class='list_main'><p class='list_title'>" + data[i].name + "</p>" +
                        "<div class='list_info'><p class='list_sales'>月销" + data[i].count + "件</p>" +
                        "<p class='list_price'>￥" + data[i].price + "</p>" +
                        "<button class='icon_btn'><span class='icon-cart'></span></button>" +
                        "</div></div></a></li>");
                }
                var aLi = $('.div8').eq(aa).children();
                for (var i = 0; i < aLi.length; i++) {
                    if (i % 2 == 0) {
                        aLi.eq(i).addClass('border_right');
                    }

                    //					if(data.length<4){
                    //						flag_updat e=false;
                    //					}
                }
            } else {
                flag_update = false;
            }
        }
    });
}

var aa = '';
var mySwiper = new Swiper('.swiper1', {
    slidesPerView: 4.5,
    slidesOffsetBefore: 15,
    onTap: function () {
//			console.log(1);
        aa = mySwiper.clickedIndex
        map(aa);
        getData(start, classify);
        mySwiper2.slideTo(aa)
    },
})

var mySwiper2 = new Swiper('.swiper2', {})


